package com.movie.modules.jf.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.movie.modules.jf.entity.MovieCommentEntity;
import com.movie.modules.jf.service.MovieCommentService;
import com.movie.common.utils.PageUtils;
import com.movie.common.utils.R;



/**
 * 电影评论表
 *
 * @author kakarot
 * @email 532050892@qq.com
 * @date 2021-08-20 01:31:10
 */
@RestController
@RequestMapping("/sys/comment")
@Api(tags = "后台评论模块")
public class MovieCommentController {
    @Autowired
    private MovieCommentService movieCommentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = movieCommentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{commentId}")
    @ApiOperation("评论详情")
    public R info(@PathVariable("commentId") Integer commentId){
		MovieCommentEntity movieComment = movieCommentService.getById(commentId);

        return R.ok().put("data", movieComment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MovieCommentEntity movieComment){
		movieCommentService.save(movieComment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MovieCommentEntity movieComment){
		movieCommentService.updateById(movieComment);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{commentId}")
    @ApiOperation("删除评论")
    public R delete(@PathVariable("commentId") Integer commentId){
        movieCommentService.removeById(commentId);
        return R.ok();
    }

}
